<?php

class Easier_rs_database {
    
    static function easier_create_table() {
        
        global $wpdb;

        $table_name = $wpdb->prefix . "easier_responsive_slider";
        $easier_slider = "CREATE TABLE IF NOT EXISTS " . $table_name . " (
                id int(11) NOT NULL AUTO_INCREMENT,
                title varchar(127) NOT NULL,
                category varchar(127) NOT NULL,
                PRIMARY KEY (id)
            )";
        $wpdb->query($easier_slider);
        return;
    }
    
    function easier_get_db() {
        global $wpdb;

        $table_name = $wpdb->prefix . "easier_responsive_slider";
        $query_slider = "SELECT * FROM " . $table_name . ";";
        $result = $wpdb->get_results( $query_slider, ARRAY_A );
        return $result;
    }
    
    function easier_get_slider_by_id($id) {
        global $wpdb;

        $table_name = $wpdb->prefix . "easier_responsive_slider";
        $query_slider = "SELECT * FROM " . $table_name . " WHERE id = $id;";
        $result = $wpdb->get_results( $query_slider, ARRAY_A );
        return $result;
    }
    
    static function easier_delete_table() {
        global $wpdb;

        $table_name = $wpdb->prefix . "easier_responsive_slider";
        $easier_slider = "DROP TABLE IF EXISTS wp_easier_responsive_slider " . $table_name . ";";
        $wpdb->query($easier_slider);
        return;
    }
    
    function easier_insert_slider($data) {
        global $wpdb;
        $wpdb->insert( $wpdb->prefix . "easier_responsive_slider", array('category' => $data[3], 'title' => $data[0]) );
    }
}